﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Threading.Tasks;
using System.Net;
using System.Web;
using System.Web.Mvc;
using HelpInfo.GetMsWeb.Models;

namespace HelpInfo.GetMsWeb.Controllers
{
    public class AgentController : Controller
    {
        private progetEntities db = new progetEntities();

        // GET: /Agent/
        public async Task<ActionResult> Index()
        {
            return View(await db.Agents.ToListAsync());
        }

        public ActionResult Agent(string  matricule)
        {
            var dataAgent =
                from a in db.Agents
                where a.Matricule == matricule
                select new AgentViewModel()
                {
                    Count = db.Agents.Count(),
                    Sexe = a.Sexe,
                    Civilité = a.Civilité
                };
            return View(dataAgent);
        }
        // GET: /Agent/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Agent agent =  db.Agents.Find(id);
            if (agent == null)
            {
                return HttpNotFound();
            }
            return View(agent);
        }

    }
}
